<?php
   $db = new Database();
   $auth = Auth::getAuth('current_user');
   $userCompany = new userQueries();
   $company = $userCompany->getCompany($auth['company_id']);
   $form_id = $_GET['formID'];
   if($_GET['view_type']=="edit"){
      $form = $db->query("SELECT * FROM tb_workspace WS 
                            WHERE WS.id={$db->escape($form_id)}","row");
      $type = "new";
   }else{
      $form = $db->query("SELECT * FROM tb_generate WS 
                            WHERE WS.id={$db->escape($form_id)}","row");
      $type = "update";
   }
   
?>

<div class="content_wrapper">
   <div class="padding_5">
      <div class="body_header_container">
         <?php
            // Workspace header
            echo functions::workspace_header("Generate","generate");
            
         ?>
         <!-- Btn droppable -->
         <div class="head " style="margin-top: 5px;">
            <div class="formbuilder_page_btn btn_content">
               <?php
                  if($form_id!=0){
                     if($_GET['view_type']=="edit"){
                        $form_id_a = $_GET['formID'];
                        $form = $db->query("SELECT * FROM tb_workspace 
                                  WHERE id={$db->escape($form_id)}","row");
                     }else{
                        $form_id_a = $_GET['printID'];
                        $form = $db->query("SELECT * FROM tb_generate 
                                  WHERE id={$db->escape($form_id)}","row");
                     }
                     
                  }
                  
               ?>
            </div>
            <?php
               if($form_id==0){
                  ?>
                  <div class="ws_btn_label  " style="margin-top: 10px;padding-left: 10px;color: gray;/* font-style: italic; */font-size: 10px;">
                     Add Your Button Here.
                  </div>
                  <?php
               }
            ?>
            
         </div>
         
         <!-- Form Pagination -->
         <div class="head display" style="margin-top: 5px;">
            <div class="padding_5 display" style="text-align: center">
               <input type="submit" class="btn-basicBtn " value="First"> <input type="submit" class="btn-basicBtn " value="Prev">
               <input type="submit" class="btn-basicBtn " value="1"> <input type="submit" class="btn-basicBtn " value="2">
               <input type="submit" class="btn-basicBtn " value="3"> <input type="submit" class="btn-basicBtn " value="4">
               <input type="submit" class="btn-basicBtn " value="5"> <input type="submit" class="btn-basicBtn " value="6">
               <input type="submit" class="btn-basicBtn " value="7"> <input type="submit" class="btn-basicBtn " value="8">
               <input type="submit" class="btn-basicBtn " value="9"> <input type="submit" class="btn-basicBtn " value="10">
               <input type="submit" class="btn-basicBtn " value="11"> <input type="submit" class="btn-basicBtn " value="12">
               <input type="submit" class="btn-basicBtn " value="Next"> <input type="submit" class="btn-basicBtn " value="Last">
            </div>
         </div>
      </div>
      
      <!-- Top Scroll -->
      
      <div style="display:table;">
         <div style="display:table-row">
            <div style="display:table-cell"></div>
            <div class="topPointerRuler-container" style="position:relative; display:table-cell;width: auto;height: 100%;border: 1px solid #ddd;border-bottom: none;">
                  <div class="topPointerRuler-tip" style="width: 10px;background-color: #000;height: 10px;cursor: pointer;"></div>
            </div>
         </div>
         <div style="display:table-row">
            <div  class="leftPointerRuler-container" style="position:relative;display:table-cell;white-space:nowrap;vertical-align:top;width: 10px;height: 600px;border: 1px solid #ddd;">
                  <div class="leftPointerRuler-tip" style="width: 10px;background-color: #000;height: 10px;cursor: pointer;"></div>
            </div>
            <div style="display:table-cell;">
               <div class="form-workspace-json display"><?php echo $form['form_json'];?></div>
               <!-- <input type="text" class="form-workspace-mobility-json display" value='<?php // echo $form['MobileContent'];?>' /> -->
               <div class="form-workspace-mobility-json display"></div>
               <div class="form-workspace-json-button display"><?php echo $form['form_buttons'];?></div>
               <div class="workspace formbuilder_ws" style="position:relative">
                  <?php
                     if($form_id!=0){
                        echo $form['form_content'];
                     }else{
                        echo $form['form_content'];
                     }
                  ?>
               </div>
               <div class="display">
                  <input type="text" name="saveType" id="saveType" value="<?php echo $type; ?>" />
                  <input type="text" name="FormId" id="FormIdPrint" value="<?php echo $form['form_id']; ?>" />
                  <input type="text" name="FormId" id="FormId" value="<?php echo $form_id_a; ?>" />
                  <input type="text" name="FormId" id="requestID" value="<?php echo $_GET['requestID']; ?>" />
                  <input type="text" name="FormId" id="trackNo" value="<?php echo $_GET['trackNo']; ?>" />
               </div>
            </div>
         </div>
      </div>
   <div>
